//
//  UIBarButtonItem+HMCategory.m
//  MeiTuanHD
//
//  Created by Romeo on 15/10/14.
//  Copyright © 2015年 itheima. All rights reserved.
//

#import "UIBarButtonItem+HMCategory.h"
#import "UIView+HMCategory.h"

@implementation UIBarButtonItem (HMCategory)

+ (instancetype)barButtonItemWithTarget:(id)target action:(SEL)action icon:(NSString *)icon hightlightIcon:(NSString *)hightlightIcon
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:icon] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:hightlightIcon] forState:UIControlStateHighlighted];
    
    // 设置按钮的图像大小
    button.size = button.currentImage.size;
    
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}

@end
